package com.demo.config.redis;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redisson 配置类
 *
 * @author vhukze
 * @date 2023/5/17 - 18:43
 */
@Configuration
public class RedissonConfig {

	@Value("${spring.data.redis.host}")
	private String host;

	@Value("${spring.data.redis.port}")
	private String port;

	@Bean
	public RedissonClient redissonClient() {
		// redis 地址为127.0.0.1:6379 时, 可以无需配置 一行代码搞定
		RedissonClient redisson = Redisson.create();

		return redisson;
		// Config config = new Config();
		// config.useSingleServer().setAddress("redis://" + host + ":" + port);
		// return Redisson.create(config);
	}

}